//
//  LFLoopViewCell.swift
//  ImageLoopDemo
//
//  Created by 夏灵烽 on 2025/1/9.
//

import UIKit

class LFLoopViewCell: UICollectionViewCell {
    
    var imageView: UIImageView?
    
    var urlStr: String? {
        didSet {
            guard let url = URL(string: urlStr ?? "") else {
                return
            }
            self.imageView?.kf.setImage(with: url)
        }
    }
    
    override init(frame: CGRect) {
        super.init(frame: frame)
        
        setupUI()
    }
    
    required init?(coder: NSCoder) {
        fatalError("init(coder:) has not been implemented")
    }
    
    func setupUI() {
        if imageView == nil {
            imageView = UIImageView()
            self.addSubview(imageView ?? UIImageView())
        }
    }
    
    override func layoutSubviews() {
        super.layoutSubviews()
        
        imageView?.frame = self.bounds
    }
}
